package com.zlj.request.encoding;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.junit.Test;

public class URLEncoding {
	
	@Test
	public void encodingDemo() throws UnsupportedEncodingException{
        String str = "张三";	
        
        //编码
        String s = URLEncoder.encode(str, "utf-8");
        System.out.println(s);  //%E5%BC%A0%E4%B8%89
        
        //解码
        s = URLDecoder.decode(s, "utf-8");
        System.out.println(s);  //张三
	}
}
